#include "BufferObject.h"

/********************************
/*          Public
/********************************/

    /********************************
    /*          Constructors
    /********************************/

        BufferObject::BufferObject(){}

    /********************************
    /*          Static
    /********************************/

        /********************************
        /*          Methods
        /********************************/

            void BufferObject::Initialize(){
                InitVBO();
                InitIBO();
            }

            void BufferObject::Bind(){
                BindVBO();
                BindIBO();
            }

            void BufferObject::FeedBuffers(){
                FeedVBO();
                FeedIBO();
                Swap();
            }

        /********************************
        /*          Properties
        /********************************/

            GLuint      BufferObject::s_WritingVBO;
            GLuint      BufferObject::s_DisplayingVBO;

            GLuint      BufferObject::s_WritingIBO;
            GLuint      BufferObject::s_DisplayingIBO;

/********************************
/*          Private
/********************************/

    /********************************
    /*          Static
    /********************************/

        /********************************
        /*          Methods
        /********************************/

            void BufferObject::InitVBO(){
                glGenBuffers(1,&(s_WritingVBO));
                glGenBuffers(1,&(s_DisplayingVBO));
            }

            void BufferObject::InitIBO(){
                glGenBuffers(1, &s_WritingIBO);
                glGenBuffers(1, &s_DisplayingIBO);
            }

            void BufferObject::BindVBO(){
                glBindBuffer(GL_ARRAY_BUFFER, s_DisplayingVBO);
            }

            void BufferObject::BindIBO(){
                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s_DisplayingIBO);
            }

            void BufferObject::FeedVBO(){
                glBindBuffer(GL_ARRAY_BUFFER, s_WritingVBO);
                glBufferData(GL_ARRAY_BUFFER,Vertex::BufferVertices.size()*sizeof(float),Vertex::Array(),GL_STREAM_DRAW);
            }

            void BufferObject::FeedIBO(){
                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s_WritingIBO);
                glBufferData(GL_ELEMENT_ARRAY_BUFFER,Triangle::Indices.size()*sizeof(GLushort),Triangle::Array(),GL_STREAM_DRAW);
            }

            void BufferObject::Swap(){
                GLuint tempValueVBO = s_WritingVBO;
                GLuint tempValueIBO = s_WritingIBO;

                s_WritingVBO        =   s_DisplayingVBO;
                s_DisplayingVBO     =   tempValueVBO;

                s_WritingIBO        =   s_DisplayingIBO;
                s_DisplayingIBO     =   tempValueIBO;
            }

        /********************************
        /*          Properties
        /********************************/








